package unit5;

import java.util.Date;

public class Employee  extends Person{
	
	private double salary;
	private Date hireDay;
	
	public Employee(String n, double salary, Date hireDay) {
		super(n);
		this.salary = salary;
		this.hireDay = hireDay;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((hireDay == null) ? 0 : hireDay.hashCode());
		long temp;
		temp = Double.doubleToLongBits(salary);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Employee other = (Employee) obj;
		if (hireDay == null) {
			if (other.hireDay != null)
				return false;
		} else if (!hireDay.equals(other.hireDay))
			return false;
		if (Double.doubleToLongBits(salary) != Double.doubleToLongBits(other.salary))
			return false;
		return true;
	}

	public Employee(String n) {
		super(n);
		// TODO Auto-generated constructor stub
	}

	@Override
	public String toString() {
		return "Employee [salary=" + salary + ", hireDay=" + hireDay + "]";
	}

	@Override
	public String getDescription() {
		// TODO Auto-generated method stub
		return String.format("an employee with a salary of $%.2f", salary);
	}
	public void raiseSalary(double byPercent)	{
		double raise=salary*byPercent/100;
		salary+=raise;
	}
}
